package edu.biwu.controller.restful;

import edu.biwu.vo.User;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/{id}")
    public User findById(@PathVariable("id") Integer uid) {
        return new User(uid, "张三", "123456");//模拟根据uid查询用户数据
    }

    @PostMapping
    public User saveUser(@RequestBody User user) {
        System.out.println("保存的用户信息:"+user);//模拟保存用户信息
        return user;
    }
    @PutMapping
    public User updateUser(@RequestBody User user){
        System.out.println("更新的用户信息:" + user);
        return user;
    }

    /**
     * DELETE /user/3
     *
     * @return
     */

    @DeleteMapping("/{id}")
    public Integer deleteUser(@PathVariable("id") Integer uid) {
        System.out.println("被删除的用户id:" + uid);
        return uid;
    }
}
